import request from './requests.js'
import qs from 'qs'
import Cookies from 'js-cookie'
import {
	select_all_warehouse_url,
	select_all_warehouse_by_duty_id_url
} from "./setting.js"

import {
	Toast, Notify
} from 'vant'

// import {  } from 'vant';



export function get_all_warehouse_(callBack) {

	request({
		method: 'GET',
		url: select_all_warehouse_url,
	}).then((response) => { //这里使用了ES6的语法
		// console.log(response) //请求成功返回的数据
		let item_list = response.data.resultBody.reverse()
		
		callBack(item_list)
		
	}).catch((error) => {
		console.log(error) //请求失败返回的数据
		Notify({
			message: '请联系管理员' + '!!!',
			type: 'danger'
		})
	})

}


//get_all_odd_by duty
export function get_all_warehouse(callBack) {


	request({
		url: select_all_warehouse_by_duty_id_url,
		method: 'post',
		data: qs.stringify({ //这里是发送给后台的数据
			duty_id: Cookies.get('duty_id')
		})
	}).then((response) => { //这里使用了ES6的语法
		// console.log(response) //请求成功返回的数据
		let result = response.data.resultBody.reverse()


		callBack(result)

	}).catch((error) => {
		// console.log(response)
		console.log(error) //请求失败返回的数据
		Toast('接口请求失败，请联系管理员！')
	})



}
export default get_all_warehouse
